import { Component, Injector } from '@angular/core';
import { IonicPage} from 'ionic-angular';
import { BasePage } from '../../basePage';
import { StorageService } from './../../../providers/StorageService';
import { UserService } from './../../../providers/UserService';

/**
 * Generated class for the CuszansPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-cuszans',
  templateUrl: 'cuszans.html',
})
export class CuszansPage extends BasePage{
    fanslist=[
    ] 
    
    userinfo = {};
    param={
      user_token:0
    }
    flag2:boolean

    constructor(injector: Injector, public userService: UserService, public stc: StorageService) {
      super(injector);
      this.userinfo = this.stc.read('userinfo');
      console.log(this.userinfo);
     
    }

  ionViewDidLoad() {
    console.log('ionViewDidLoad CuszansPage');
   this.getMyfan()
   console.log(this.fanslist)
  }
  
/**获取后台相应数据 */
  async getMyfan(){
    this.fanslist=[];
    this.param.user_token=this.userinfo['user_id'];
    let result =await this.userService. getFans(this.param);
    console.log(result);
    if (result.code != 1) {
      this.flag2=true
    }else{
      if(this.userinfo['user_type']==1){
        this.fanslist = result.data.artist_fans;
      }else if(this.userinfo['user_type']==2){
        this.fanslist = result.data.shop_fans;
      }
      

      this.flag2 =false;
    }
  }
  dismissCLI() {
    // this.navCtrl.push('personal');
    this.viewCtrl.dismiss()
  }
}
